package com.doget.data.db;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import io.reactivex.Completable;
import io.reactivex.Flowable;

@Dao
public interface UserInfoDao {


    @Query("SELECT * FROM userInfo")
    Flowable<List<UserInfo>> getAll();

    @Query("SELECT * FROM userInfo WHERE uid IN (:userIds)")
    List<UserInfo> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM userInfo WHERE name LIKE :first AND "
            + "againName LIKE :last LIMIT 1")
    UserInfo findByName(String first, String last);

    @Insert
    Completable insertAll(UserInfo... users);

    @Delete
    void delete(UserInfo user);


    //    @Query("SELECT * FROM userInfo WHERE name LIKE '%' || :name" || '%')
    @Query("SELECT * FROM userInfo WHERE name LIKE :name AND " + "waiyu LIKE :waiyu")
    Flowable<List<UserInfo>> queryUser(String name, String waiyu);

    //@Query("SELECT * FROM userInfo WHERE name LIKE '%' || :name" || '%')
    @Query("SELECT * FROM userInfo WHERE name LIKE '%' || :name || '%'" + "AND waiyu LIKE '%' || :waiyu || '%' ")
    Flowable<List<UserInfo>> queryUserList(String name, String waiyu);

}
